//
//  InputPasswordViewController.m
//  AI
//
//  Created by zjhc on 2018/1/8.
//  Copyright © 2018年 zjhc. All rights reserved.
//

#import "InputPasswordViewController.h"
#import "LlbTextField.h"
#import "UrlManage.h"

@interface InputPasswordViewController ()
@property (weak, nonatomic) IBOutlet LlbTextField *password;//密码
@property (weak, nonatomic) IBOutlet LlbTextField *repeatPassword;//重复输入密码
- (IBAction)submitAction:(id)sender;//提交事件
@property (weak, nonatomic) IBOutlet UIButton *submitButton;//提交按钮


@end

@implementation InputPasswordViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBar.hidden = NO;
    self.password.horizontalPadding = 15;
    self.repeatPassword.horizontalPadding = 15;
    self.password.secureTextEntry = YES;
    self.repeatPassword.secureTextEntry = YES;
    self.submitButton.layer.cornerRadius = 8.0;

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - 提交事件
- (IBAction)submitAction:(id)sender {
    
    if([self.password.text isEqualToString:@""]) {
        [HXAlertViewEx showInTitle:@"提示" Message:@"请输入密码" ViewController:self];
        return;
    }
    
    if([self.repeatPassword.text isEqualToString:@""]) {
        [HXAlertViewEx showInTitle:@"提示" Message:@"请重复输入密码" ViewController:self];
        return;
    }

    if (![self.password.text isEqualToString:self.repeatPassword.text]) {
        [HXAlertViewEx showInTitle:@"提示" Message:@"密码输入不一致" ViewController:self];
    }
    
    [WTHttpRequest requestJsonPutWithUrlStr:[UrlManage sharedManager].resetPassord params:@{@"telphone":self.phone,@"smsCode":self.authCode,@"password":self.password.text,@"confirmPassword":self.repeatPassword.text} onComplete:^(NSError *error, NSDictionary *resultJson) {
        
        if (!error) {
            [HXAlertViewEx showInTitle:@"提示" Message:@"重置密码成功" ViewController:self];
        } else {
            [HXAlertViewEx showInTitle:@"提示" Message:error.domain ViewController:self];
        }
    }];
    
}
@end
